<?php
namespace Modules\Asset\Http\Controllers\Client\V1;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use \Modules\Asset\Entities\RedpackSku;

use Validator;
use ThrowException;
use DB;
use Setting;

class RedpackSkuController extends Controller
{
    // 获取开奖列表
    public function index(Request $req)
    {
        $rule = [
        ];
        Validator::make($req->all(), $rule)->fails() && ThrowException::BadRequest(); 

        // $class = @config('activity.map')[$activityType] ?: ThrowException::Conflict('无效的活动类型');

        $options['scopes'] = ['onStock'];
        $options['order_by'] = ['list_weight' => 'desc'];

        $options['only'] = [
            'id',
            'uuid',
            'redpack',
            'money_price'
        ];


        // 获取积分充值设置
        $setting = @Setting::get('sys_redpack_sku') ?: [];
        if (@$setting['rule']) {
            $setting['rule'] = explode("\n", $setting['rule']);
        }


        $list = RedpackSku::getList($options);
        $res = $list->generateListResponse();

        $res['setting'] = $setting;

        return $res;
    }
}
